Skip to content

Add extends property for configuration inheritance - #772

Open
Sam Frost (SamuelFrost) wants to merge 4 commits into
devcontainers:mainfrom
SamuelFrost:extends
Open

Sam Frost (SamuelFrost) wants to merge 4 commits into
devcontainers:mainfrom
SamuelFrost:extends

Conversation

@SamuelFrost

@SamuelFrost Sam Frost (SamuelFrost) commented Sep 18, 2026 •

Copy link
Copy Markdown

Summary

Teams sharing a codebase often need slightly different devcontainer.json settings without copying the whole file. Issue #22 proposed an extends property for that.

This PR adds extends and extendsMergeMode to the schema and reference docs so one configuration can inherit another JSON or JSONC file in the same repository, with selectable merge behavior.

Companion Dev Container CLI implementation: devcontainers/cli#1306

Properties

Property Type Description
extends string Relative path to a JSON or JSONC base file in the same repository. Merged with this file per extendsMergeMode. Not present in merged output. Absolute paths and URLs are not supported. Referenced files may themselves use extends.
extendsMergeMode string Optional. combine (default) or override. Read from the file that declares extends. Not present in merged output.

Merge behavior

Use combine on a layer for additive object/array merging; use override for a thin layer that replaces specific properties.

combine (default)

Same merge logic as image metadata: array union where applicable, hostRequirements max, object maps merged per key with the current file winning conflicts, boolean init / privileged true if any side is true, scalars last-wins, and so on.

override

Each top-level property set on the current file fully replaces values from the extends target; omitted keys keep the resolved target's values.

Changes

  • schemas/devContainer.base.schema.json: extends, extendsMergeMode.
  • docs/specs/devcontainerjson-reference.md: general properties table entries, Configuration inheritance section (examples from spec#22, combine / override semantics).
  • docs/specs/devcontainer-reference.md: one sentence in the merge-logic table notes linking inheritance to the same merge rules (Configuration inheritance).

Technical choices (from CLI #311 review)

Issue #22 originally described Docker Compose–style deep merge. Review of CLI PR #311 settled on image metadata merge for the default (combine) path. Nested extends is allowed; cycles, absolute paths, and URLs are not. Cross-repository references remain future work per spec#22.

Test plan

Additional decisions (beyond original spec#22 / CLI #311 review)

Decision Commit
Document extendsMergeMode alongside extends 9f8d6d7
override documented as full top-level replace (spread semantics), not shallow merge of object maps / hostRequirements c221072

Full branch commit series: 1b7c38d → 9f8d6d7 → c221072.

Follow-up

CONTRIBUTING.md asks for a PR against the devcontainer.json reference in vscode-docs once maintainers are on board.

Finalizes spec#22.

Document and schema-enable the extends keyword from devcontainers#22, merging referenced files with the existing image metadata merge logic.
@SamuelFrost

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree

@SamuelFrost
Sam Frost (SamuelFrost) marked this pull request as ready for review September 24, 2026 05:47
@SamuelFrost
Sam Frost (SamuelFrost) requested a review from a team as a code owner September 24, 2026 05:48
Comment thread docs/specs/devcontainerjson-reference.md
Schema and reference docs for combine (default) and override merge when
using extends, aligned with the Dev Container CLI behavior.
Align spec and schema with spread semantics: set properties replace the
inherited value entirely; omitted properties keep the chain below.
@SamuelFrost

Sam Frost (SamuelFrost) commented Sep 24, 2026 •

Copy link
Copy Markdown
Author

Requesting review from Chuck Lantz (@Chuxel) joshspicer Samruddhi Khandale (@samruddhikhandale) Christof Marti (@chrmarti) and @devcontainers/maintainers when you have bandwidth.

This documents and schema-enables configuration inheritance for spec#22 (finalization label): extends plus extendsMergeMode (combine | override), aligned with the reference implementation in devcontainers/cli#1306.

Docs:

  • devcontainerjson-reference.md: property table + Configuration inheritance (examples from spec#22, both merge modes).
  • devcontainer-reference.md: ties inheritance to existing merge logic.
  • devContainer.base.schema.json: extends, extendsMergeMode.

Note on semantics: default combine follows image-metadata merge (not Compose deep-merge from the original spec#22 text). override is documented as full top-level replace when set, not shallow map merge.

I'd appreciate review on normative wording and whether anything should change before or in parallel with CLI PR #1306. vscode-docs follow-up can wait per CONTRIBUTING guidelines. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants